/***********************************
 * Filename : test_main.c
 * Author :   taopeng
 * *********************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include "threadpool.h"

void test_task(void *arg)
{
    long id = (long)arg;

    printf("task[%ld] enter\r\n", id);
    sleep(3);

    return;
}

int32_t main(int32_t argc, char *argv[])
{
    tThreadpoolInfo *threadpool;
    long id;

    threadpool = threadpool_create(128, 8, 64);
    if (NULL == threadpool)
        return -1;

    for (id = 1; id <= 1024;)
    {
        if (0 != threadpool_addtask(threadpool, (THREADPOOLTASKFUNC)test_task, (void *)id, NULL))
        {
            sleep(1);
            continue;
        }

        id++;
    }

    sleep(30);

    threadpool_destroy(threadpool);
    return 0;
}
